package com.roger.cmdkit.demo;

import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
import java.util.Stack;

public class DataStructure {

    public static void main(String[] arg){
        //enum
        System.out.println(week.Mon.getDay());

        //stack
        Stack<Integer> st = new Stack<Integer>();
        st.push(1);
        st.push(2);
        st.push(3);
        System.out.println(st);
        st.pop();
        System.out.println(st);
        st.clear();
        System.out.println(st);

        //hash table
        Hashtable ht = new Hashtable();
        Enumeration num;
        ht.put("first","1");
        ht.put("second","2");
        ht.put("third","3");
        num=ht.keys();
        while(num.hasMoreElements()) {
            String s =(String)num.nextElement();
            System.out.println(s+ht.get(s));
        }
        ht.put("third",new Integer(3+2));
        System.out.println(ht.get("third"));

        //list
        List<String> list=new ArrayList<String>();
        list.add("Hello");
        list.add("World");
        for (String str : list) {
            System.out.println(str);
        }

        //map
        Map<String, String> map = new HashMap<String, String>();
        map.put("1", "Hello");
        map.put("2", "java");
        for (String key : map.keySet()) {
            System.out.println("key= "+ key + ",value= " + map.get(key));
        }
    }

    enum week{
        Mon("Monday"), Tue("Tuesday"), Wed("Wednesday"), Thu("Thursday"), Fri( "Friday"), Sat("Saturday"), Sun("Sunday");
        private final String day;
        week(String day) {
            this.day = day;
        }
        public String getDay() {
            return day;
        }
    }
}
